//
//  lambda.hpp
//  utilities
//
//  Created by Sam Jaffe on 12/8/12.
//  Copyright (c) 2012 Sam Jaffe. All rights reserved.
//

#pragma once

#include <functional>

namespace math {
    namespace lambda {
        template <typename _Signature>
        class lambda;
        
        template <class R, class Arg, class... Args>
        class lambda<R(Arg, Args...)> {
            std::function<R(Arg, Args...)> f;
        public:
            lambda(std::function<R(Arg, Args...)> func) : f(func) {}
            
            lambda<R(Args...)> operator() (Arg arg) {
                return lambda<R(Args...)>(std::bind(f, arg));
            }
        };
        
        template <class R, class Arg>
        class lambda<R(Arg)> {
            std::function<R(Arg)> f;
        public:
            lambda(std::function<R(Arg)> func) : f(func) {}
            
            R operator() (Arg arg) {
                return f(arg);
            }
        };
    }
}
